package apiday02.regexapi;

import java.util.Scanner;

public class ReplaceAllDemo {

	public static void main(String[] args) {
		/*
		 * replaceAll
		 * 将正则表达式匹配到的 子字符串 全部替换掉
		 */
		Scanner in = new Scanner(System.in);
		System.out.print("输入信息:");
		String str = in.nextLine();
		String regex = "我[去草艹]";
		str = str.replaceAll(regex, "XX");
		System.out.println(str);

        //实现和谐用语
		String regex1 = "(wqnmlgb|cnm|sb|2b|nc|tmd|djb)";
		String message = "wqnmlgb!你这个djb！你怎么这么nc,你个2b!cnm!";
		message = message.replaceAll(regex1, "***");
		System.out.println(message);  //输出结果：***!你这个***！你怎么这么***,你个***!***!
	}

}
